package com.dflc.config;

import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器
 * @author tqx
 * @version 1.0.0.0
 * <p>Title: LoginInterceptor </p >
 * <p>Description: 拦截器  </p >
 * Package: com.dflc.controller
 * Company: 数字涪陵
 * Copyright: Copyright(c) 产品研发与安全部
 * Date: 2023年04月102日 9:22
 */
@Configuration
public class WebConfig implements WebMvcConfigurer{


    private static final String[] exclude_path = {
            "/sysLoginUser/**"
    };


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截器
        registry.addInterceptor(new SaInterceptor(handle -> {
                    StpUtil.checkLogin();
                }))
                .excludePathPatterns(exclude_path)
                    .addPathPatterns("/**");
    }

}
